#!/usr/bin/python3
# -*- coding: utf-8 -*-
"""
@Time        : 2021/12/2 14:52
@Author      : Albert Darren
@Contact     : 2563491540@qq.com
@File        : haar_like.py
@Version     : Version 1.0.0
@Description : TODO
@Created By  : PyCharm
"""
from skimage.transform import integral_image
from skimage.feature import haar_like_feature_coord
from skimage.feature import draw_haar_like_feature
import numpy as np
import matplotlib.pyplot as plt
from DIP_experiment_5.util import contrast_show

im = np.zeros((8, 8), dtype=np.uint8)
int_im = integral_image(im)
feat_t = ["type-2-x", "type-2-y", "type-3-x", "type-3-y", "type-4"]
im_dicts = {}
for feat in feat_t:
    feature_coord, _ = haar_like_feature_coord(im.shape[1], im.shape[0], feat)
    image = draw_haar_like_feature(int_im, 0, 0, im.shape[1], im.shape[0],
                                   feature_coord=feature_coord, max_n_features=1, random_state=1)
    im_dicts[feat] = image
plt.figure().suptitle(t="The visualization of five different types of haar like features")
contrast_show(im_dicts, (2, 3))
